package com.example.shixun1.activity;

import android.os.Bundle;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.example.shixun1.R;
import com.example.shixun1.model.Article;
import java.text.SimpleDateFormat;
import java.util.Locale;

public class ArticleDetailActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_article_detail);

        Article article = (Article) getIntent().getSerializableExtra("article");

        TextView tvTitle = findViewById(R.id.tv_detail_title);
        TextView tvAuthor = findViewById(R.id.tv_detail_author);
        TextView tvTime = findViewById(R.id.tv_detail_time);
        TextView tvContent = findViewById(R.id.tv_detail_content);

        tvTitle.setText(article.getTitle());
        tvAuthor.setText("作者：" + article.getAuthor());
        tvTime.setText("发布时间：" + new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault())
                .format(article.getPublishTime()));
        tvContent.setText(article.getContent());
    }
}